
<div class="wrapMain">
<?php if($_SESSION['mobile']==0){?>
<div style="text-align:center"><input type="hidden" name="optionvalue" id="menu-search-box" class="input-medium" data-placeholder="Nhập Tên Truyện ..."   /></div><Br/>
	<?php }?>
    <div id="row">
		 <div class="col-md-12"> 
   			<ul class="breadcrumb" style="background-color:#fff">
        	<li itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="<?php echo HOME ?>" itemprop="url"><span itemprop="title"><i class="fa fa-home"></i></span></a></li>
            <li itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="<?php echo HOME ?>truyen" itemprop="url"><span itemprop="title">Truyện</span></a></li>
             <li itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><?php echo $data['truyen']['theloai2'][2] ?></li>
            <li itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="<?php echo url_truyen($data['truyen']['id'],$data['truyen']['alias']); ?>" itemprop="url"><span itemprop="title"><?php echo short_str($data['truyen']['ten'],8)  ?></span></a></li>
            <li><span><?php echo short_str($data['ten'],17)?></span></li>
       	 </ul>
   		  <!-- START TRUYEN DE CU -->
          <div class="chuong_detail_head">
                <h1 class="text-center name "><a href="<?php echo url_truyen($data['truyen']['id'],$data['truyen']['alias']); ?>"><?php echo $data['truyen']['ten']  ?></a></h1>
                <h2 class="text-center tinhtrang">( <?php echo $data['truyen']['tinhtrang-text']  ?> )</h2>
                <h2 class="text-center capnhat"> ( Chương Mới Nhất : <a href="<?php echo $data['truyen']['chuongmoinhat_url']  ?>"><span style="color:#999; font-weight:normal"> <?php echo $data['truyen']['chuongmoinhat']  ?></span> </a> )</h2>
                
                            <?php if($data['truyen']['sochuong']>0){ ?>    
            <div class="row" style="background-color:#fafafa; padding:4px; margin:5px; border-radius:3px" >
                <div class="col-md-6"><i class="fa fa-chevron-down"> </i> Chọn Nhanh   <span class="badge" style="line-height:20px">
               <input type="text" class="curchuong" style="color:#000; width:35px; border:none; border-radius:3px" value="<?php echo $data['thutu']; ?>" id="curchuong">
				<?php echo "&nbsp;/&nbsp;".$data['truyen']['sochuong'];?></span>  &nbsp; <a  class="btn btn-warning btn-sm fchuong">Go <i class="fa fa-angle-double-right"></i> </a>
             
                </div>
                <div class="col-md-6">
                <div style="height:10px"></div>
               		 <div class="nouislider"></div>
                </div>
            </div>
          
          <script>
		  $(function(){
			
        	
        	$('.nouislider').noUiSlider({
					 range: [0,<?php echo $data['truyen']['sochuong']; ?>]
					,start:<?php echo $data['thutu']; ?>
					,step: 1
					,handles: 1
					,serialization: {
						resolution: 1,
						to: [ $(".curchuong"), 'val' ]
					}
				});
				
			$('.fchuong').live('click', function(e){
				e.preventDefault();
				$.ajax({
					url : "index.php",
					type : 'POST',
				
					data : {
						module: 'truyen', 
						act :'fchuong', 
						thutu : $('#curchuong').val(),
						alias:'<?php echo $data['truyen']['alias'];?>',
						truyen: <?php echo $data['truyen']['id']; ?>
					
					},
					
					success : function(data){
						if($.trim(data)!='no_result'){
						location.href=data;
						}else{
							alert('Chương Không tồn tại, xin vui lòng kiểm tra lại');
						}
							
				
					}
				});
			
			
		});	//fchuong click	
     })
		  </script>
          <?php }?>
        </div>
		  <div class="panel panel-default">
 			 <div class="panel-heading">
         		   		<div class="btn-group pull-center" >
                      <?php if($data['previous']){ ?>  <a class="btn btn-primary" role="button" href="<?php echo url_truyen_chuong($data['previous']['id'],$data['previous']['alias'],$data['truyen']['alias']) ?>"><i class="fa fa-long-arrow-left"></i> Chương Trước</a><?php }?>
                          <?php if($data['next']){ ?> <a class="btn btn-primary" role="button" href="<?php echo url_truyen_chuong($data['next']['id'],$data['next']['alias'],$data['truyen']['alias']) ?>">Chương Sau <i class="fa fa-long-arrow-right"></i> </a><?php }?>
              			 </div>
                         
                      
         </div>
  		<div class="panel-body">
        
  		
  				<h1 class="text-center" style="line-height:30px; color:#3598ce"><?php echo $data['truyen']['ten']."<br/> ".$data['ten']; ?></h1>
               					<span class="pull-right"><img src="public/images/zoom-out.png" class="zoom-out zoom-font" /> &nbsp;&nbsp;<img src="public/images/zoom-in.png" class="zoom-in zoom-font" /></span>
                                <div class="clearfix"></div>
                                <?php if($data['image']==1){ ?><div class="alert alert-danger">Chương Truyện có hình ảnh, vì thế bạn hãy đợi load xong hết rùi mới đọc nhé</div><?php }?>
                                
                                
          				<div class="chuong_noidung">
                        	<?php echo $data['noidung']; ?>
                        </div> <!-- End of chuong_noidung -->
         
         <?php if($_SESSION['mobile']==0){?>
  				<div class="alert alert-info text-center"><strong>Chú Ý :</strong> Bạn đang đọc truyện <?php echo $data['truyen']['ten']." ".$data['ten']; ?> <Br/>
                			
                            	<a href="" class="btn btn-primary report_truyen">Báo Lỗi Chương <i class="fa fa-warning"></i></a>
                             
                              
                                <a href="" class="btn btn-primary note_story">Đánh Dấu <i class="fa fa-bookmark"></i> </a>
                                 <a  class="btn btn-primary show_story_history">Lịch Sử Đọc Truyện  </a>
                
                </div>
                <?php }else{ ?>
               <div class="alert alert-warning" style="text-align:center"> <a href="" class="report_truyen">Báo Lỗi Chương <i class="fa fa-warning"></i></a></div>
                <?php }?>
                 <?php if($_SESSION['mobile']==0){?>
                 	<h2 style="font-size:10px; color:#999"><i class="fa fa-tag"></i> Từ Khóa :Đọc truyện <?php echo $data['truyen']['ten']." ".$data['truyen']['tacgia']." ".$data['ten'];?>,Đọc truyện <?php echo $data['truyen']['ten']." ".$data['ten'];?>,doc truyen <?php echo $data['truyen']['ten']." ".$data['ten'];?>,<?php echo $data['truyen']['ten']." ".$data['ten'];?></h2>
                <div class="row">
                	<div class="col-md-6">
                    	<div><strong>Click Like Mong trên facebook để tham gia chém gió cùng cộng đồng và ủng hộ tinh thần chúng tôi ^^</strong></div>
                        <div class="fb-like" data-href="<?php echo FB_FANPAGE;?>" data-send="true"  data-show-faces="true" ></div>
                    </div>
                    <div class="col-md-6">
                   <strong> Cám ơn bạn đã đọc truyện tại Mộng.VN . Bạn có thể chia sẻ với chúng tôi bằng cách: </strong>
                    	<ul>
                        
                        	<li>Đăng Và Upload Truyện</li>
                            <li>Chia sẻ Video Clip</li>
                            <li>Đăng bài trên Blog</li>
                        </ul>
                    </div>
                </div>
                <?php }?>
                
                
                
                
                 <!--Adsense -->
        <?php
		if($_SESSION['mobile']==0){
		?>
        <div  style="width:680px; margin:auto">
        
          
<!-- 300x250, created 9/30/10 -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ADSENSE MONG -HOME -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-6643486112344004"
     data-ad-slot="6332468874"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
         
          
<!-- 300x250, created 9/30/10 -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ADSENSE MONG -HOME -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-6643486112344004"
     data-ad-slot="6332468874"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
      
        <?php
		}else{
		 ?>
         <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Mobile 320x100 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:320px;height:100px"
     data-ad-client="ca-pub-6643486112344004"
     data-ad-slot="1902269279"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Mobile 320x100 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:320px;height:100px"
     data-ad-client="ca-pub-6643486112344004"
     data-ad-slot="1902269279"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
         <?php }?>
        <!--End of adsense -->
                
                
  		</div> <!-- End of panel body -->
        
        <div class="panel-footer">
        			<div class="btn-group" style="text-align:center" >
                        <div class="btn-group" >
                      <?php if($data['previous']){ ?>  <a class="btn btn-primary" role="button" href="<?php echo url_truyen_chuong($data['previous']['id'],$data['previous']['alias'],$data['truyen']['alias']) ?>"><i class="fa fa-long-arrow-left"></i> Chương Trước</a><?php }?>
                          <?php if($data['next']){ ?> <a class="btn btn-primary" role="button" href="<?php echo url_truyen_chuong($data['next']['id'],$data['next']['alias'],$data['truyen']['alias']) ?>">Chương Sau <i class="fa fa-long-arrow-right"></i> </a><?php }?>
              			 </div>
                        
                      </div>
                      
                    
        </div><!-- End panel footer -->
		</div> <!-- End of panel -->

      <ul class="breadcrumb" style="background-color:#fff">
        	<li><a href="<?php echo HOME ?>"><i class="fa fa-home"></i></a></li>
            <li><a href="<?php echo HOME ?>truyen">Truyện</a></li>
             <li><?php echo $data['truyen']['theloai2'][2] ?></li>
            <li><a href="<?php echo url_truyen($data['truyen']['id'],$data['truyen']['alias']); ?>"><?php echo short_str($data['truyen']['ten'],8)  ?></a></li>
            <li><span><?php echo short_str($data['ten'],17)?></span></li>
       	 </ul>
        
        


</div> <!-- COL MD 9 -->
  
               



	
	</div><!-- end row -->
    
    
      <div class="panel panel-default">
 			 <div class="panel-heading">
         		   	
          		<strong>   Thảo Luận về truyện này</strong>
         </div>
  		<div class="panel-body">
  		
  		
  		
  		
  		
	<script>
			window.fbAsyncInit = function() {
 FB.init({appId: '<?php echo FB_ID;?>', status: true, cookie: true, xfbml: true});

     FB.Event.subscribe('comment.create', function(response) {
          var commentQuery = FB.Data.query('SELECT fromid, text FROM comment WHERE post_fbid=\'' + response.commentID + '\' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url=\'' + response.href + '\')');
      var user = FB.Data.query(
       "select name, id, url, pic_square from profile where id in"
     + "(select fromid from {0})", commentQuery);
 
  FB.Data.waitOn([commentQuery,user], function () {
   ct = commentQuery.value[0].text;

   u = user.value[0].name;
   td='<?php echo2($data['truyen']['ten']." ".$data['ten']) ?>';
   url='<?php echo url() ?>';
   m='truyen';
   ip='<?php echo get_ip(); ?>';
   id='<?php echo $data['truyen']['id']; ?>';
	// Query get user info with fromid
	//Send data to server using ajax ------ KAKAKAKAKAKA
			 var   values='comment_user='+u+'&comment_tieude='+td+'&comment_url='+url+'&comment_type='+m+'&ip='+ip+'&comment_id='+id+
    '&comment_content='+ct+'&module=user&act=ajax&add_comment';
	
  	$.ajax({
      url: "index.php",
      type: "post",
      data: values,
      success: function(data){
          },
   
    }); 
	
    // Use your preferred way to inform the server to save comment
     });
 });         
 };
 </script>  
  <style>.fb_iframe_widget,
.fb_iframe_widget span,
.fb_iframe_widget iframe[style]  {width: 100% !important;}</style>
         <div class="fb-comments" data-href="<?php echo url_truyen($data['truyen']['id'],$data['truyen']['alias']); ?>" data-numposts="5" data-colorscheme="light"></div>
        </div>

</div><!-- end wrapMain -->
<div class="clearfix"></div>



<script type="text/javascript">
	$(document).ready(function(){
		
		//$.cookie('fontsize', 15 , { expires: 7, path: '/' });
		//$.removeCookie('fontsize');
		fontsize = $.cookie('fontsize');
		if(fontsize == null || fontsize == '' || typeof fontsize == 'undefined'){
			
		}else{
			if(fontsize < 11 || fontsize > 25){
				fontsize = 16;
			}
			$('.chuong_noidung').css('font-size', fontsize + 'px');
		}
		
		$('.zoom-font').live('click', function(e){
			fontsize = $.cookie('fontsize');
			if(fontsize == null || fontsize == '' || typeof fontsize == 'undefined'){
				fontsize = 16;
			}
			minsize = 11;
			maxsize = 25;
			if($(this).hasClass('zoom-in')){
				if(fontsize < maxsize){
					fontsize = parseInt(fontsize) + 1;
				}
			}else{
				if(fontsize > minsize){
					fontsize = parseInt(fontsize) - 1;
				}
			}
			$.cookie('fontsize', fontsize, { expires: 30, path: '/' });
			$('.chuong_noidung').css('font-size', fontsize + 'px');
		});
		
		
		 $('.report_truyen').live('click',function(e){
			 	/*
			 	Truyền vào truyen_id, truyen_chuong_id, url, noidung
			 	*/
				e.preventDefault();
				
				//dataHref = window.location.pathname;
				//truyen_id = $(this).parent().parent().parent().attr('data-rel');
				
				if(!$('#modal_truyen_report').length){
					$.ajax({
						url: baseUrl + 'index.php?module=ajax&act=ajax&get_modal_truyen_report=1',
						type: 'POST',
						success: function(data){
							$('body').append(data);
							$('#modal_truyen_report').modal();
							//$('#modal_report').show();
						}
					});
					
				}else{
					$('#modal_truyen_report').modal();
				}
			});


		 $('.submit_truyen_report').live('click', function(e){
				e.preventDefault();
				truyen_id = '<?= $data['truyen']['id']; ?>';
				truyen_chuong_id = '<?= $data['id']; ?>';
				url = document.URL;
				
				$(".alert").remove();
				$.ajax({
					url: baseUrl + 'index.php?module=ajax&act=ajax&send_truyen_report=1',
					type: 'POST',
					data: { 
						txt_report_content: $('#txt_report_content').val(),
						truyen_id: truyen_id,
						truyen_chuong_id: truyen_chuong_id,
						url: url
					},
					
					success: function(data){
						if(data) newData = JSON.parse(data);
						console.log(newData);
						if(newData.errors){
		    				$.each(newData.errors, function(e, error){
			    				if(e != 'error'){
			    					$('#' + e).parent().append('<div id="'+e+'_error" class="alert alert-danger alert-dismissable" style="display: none;"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+error+'</div>');
			    					$('#' + e + '_error').slideDown('fast');
			    				}else{

									
			    				}
		    				});
						}else if(newData.message){
							
							//console.log($('#txt_report_content_' + $(this).attr('data-href')).val());
							$('#modal-content').append('<div id="report_success" class="alert alert-success alert-dismissable" style="display:none;">Cám ơn bạn đã báo cáo nội dung xấu. Chúng tôi sẽ kiểm tra bài viết trong thời gian sớm nhất.</div>');
							//$('#report_success').slideDown('fast');
							var test = $('#report_success').slideDown('fast').delay(1000).slideUp('fast', function(){$('#modal_truyen_report').modal('hide');});
							$('#txt_report_content').val('');
							
						}
					}
				});
			});

			$('.note_story').live('click',function(e){
				e.preventDefault();
				username = '<?= $_SESSION['user']['username']; ?>';
				if(!username){
					window.location.href = '<?= LOGIN ?>';
					return;
				}
				id = '<?= $data['id']; ?>';
				truyen_id = '<?= $data['truyen']['id']; ?>';
				ten = '<?= $data['ten']; ?>';
				url = '<?php echo url(); ?>';
				username = '<?= $_SESSION['user']['username']; ?>';
				
				$.ajax({
					url: 'index.php?module=user&act=ajax&note_chapt=1',
					type: 'POST',
					data: {id: id,truyen_id: truyen_id, ten: ten, url: url, username: username},
					success: function(data){
						if(data) newData = $.parseJSON(data);
						if(newData.error){
							popupMessage('Lỗi', [newData.error], 'alert-danger');
						}else if(newData.message){
							popupMessage('Thành công', [newData.message], 'alert-success');
						}
					},
				});
			});

			
	});
</script>
<?php
if($_SESSION['mobile']!=0){
	 truyen_render_theloai(); 
}
?>